package com.ruoyi.shop.service;

import java.util.List;

import com.ruoyi.shop.domain.Orders;
import com.ruoyi.shop.mapper.OrderdetailMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.shop.mapper.OrdersMapper;

/**
 * ordersService业务层处理
 *
 * @author ruoyi
 * @date 2025-06-08
 */
@Service
public class OrdersServiceImpl implements IOrdersService
{
    @Autowired
    private OrdersMapper ordersMapper;
    @Autowired
    private OrderdetailMapper orderdetailMapper;
    /**
     * 查询orders
     *
     * @param orderid orders主键
     * @return orders
     */
    @Override
    public Orders selectOrdersByOrderid(Long orderid)
    {
        return ordersMapper.selectOrdersByOrderid(orderid);
    }
    @Override
    public Orders getOrdersByOrdersn(String ordersn) {
        return ordersMapper.getOrdersByOrdersn(ordersn);
    }
    /**
     * 查询orders列表
     *
     * @param orders orders
     * @return orders
     */
    @Override
    public List<Orders> selectOrdersList(Orders orders)
    {
        return ordersMapper.selectOrdersList(orders);
    }

    /**
     * 新增orders
     *
     * @param orders orders
     * @return 结果
     */
    @Override
    public int insertOrders(Orders orders)
    {
        int i=ordersMapper.insertOrders(orders);
        if (i>0){
            int j=orderdetailMapper.insertOrderdetails(orders.getOrderdetailList());
            if (j>0){
                return 1;
            }else {
                return 0;
            }
        }else {
            return 0;
        }
    }

    /**
     * 修改orders
     *
     * @param orders orders
     * @return 结果
     */
    @Override
    public int updateOrders(Orders orders)
    {
        return ordersMapper.updateOrders(orders);
    }

    /**
     * 批量删除orders
     *
     * @param orderids 需要删除的orders主键
     * @return 结果
     */
    @Override
    public int deleteOrdersByOrderids(Long[] orderids)
    {
        return ordersMapper.deleteOrdersByOrderids(orderids);
    }

    /**
     * 删除orders信息
     *
     * @param orderid orders主键
     * @return 结果
     */
    @Override
    public int deleteOrdersByOrderid(Long orderid)
    {
        return ordersMapper.deleteOrdersByOrderid(orderid);
    }
}
